/**
 * @fileOverview 基于jquery节点封装的视图基类
 * @author goodzsq@gmail.com
 */
var BaseClass = gg.module('ui.jq.Component');
module.exports = gg.createClass({
    attributes: {
        title: {
            type: 'datatype.String',
            setter: function(v) {
                this.defaultSetter('title', v);
                var el = this.el.find('>.panel-heading');
                if (el.length === 0) {
                    el = this._buildHtml({class: 'panel-heading', html: v});
                    if (this.el.children().length > 0) {
                        this.el.children().first().before(el);
                    } else {
                        this.el.append(el);
                    }
                } else {
                    el.html(v);
                }
            }
        },
        html: {
            type: 'datatype.String',
            setter: function(v) {
                this.defaultSetter('html', v);
                var container = this.el.children('.panel-body');
                if (container.length === 0) {
                    container = this._buildHtml({class: 'panel-body'});
                    this.el.append(container);
                }
                this.el.children('.panel-body').html(v);
            }
        },
        container: {
            type: 'ui.jq.Container',
            setter: function(v, oldValue) {
                this.defaultSetter('container', v);
                if(oldValue && oldValue.el){
                    oldValue.el.remove();
                }
                if(v && v.el){
                    this.el.append(v.el);
                }
            }
        }
    },
    methods: {
        /**
         * @override
         */
        createElement: function() {
            var css = 'ui panel panel-default';
            this.el = this._buildHtml({id: this.cid, class: css});
        }
    },
    events: {
    }
}, BaseClass, []);